import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/3/17 10:17
 */

public class Solution {
    public int findPeakElement(int[] nums){
        int left = 0,right = nums.length - 1;
        while(left < right){
            int mid = left + (right - left)/2;
            if(nums[mid] < nums[mid + 1])
                left = mid + 1;
            else
                right = mid;
        }
        return left;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int len = in.nextInt();
            int[] nums = new int[len];
            for (int i = 0; i < len; i++) {
                nums[i] = in.nextInt();
            }
            Solution solution = new Solution();
            System.out.println(solution.findPeakElement(nums));
        }
    }
}
